/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.llantas.Dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.llantas.modelo.Vendedor;

/**
 *
 * @author manuel
 */
@Stateless
public class VendedorDao extends AbstractDao<Vendedor> implements VendedorDaoLocal {
    @PersistenceContext(unitName = "llantas-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public VendedorDao() {
        super(Vendedor.class);
    }
    
     public boolean findDuplicity(Vendedor salesman) {
      // selecionar consulta
        Query q=em.createNamedQuery("Vendedor.findDuplicity");
       //poner parametros
        q.setParameter("nombre", salesman.getNombre());
        q.setParameter("apeidoPaterno", salesman.getApeidoPaterno());
       
        //ejecutar la consulta
        return !q.getResultList().isEmpty();
    }
    public Vendedor findDuplicity(VendedorDao salesman) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
